package com.noble.meether.logic.third.share.dialog;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.noble.meether.R;
import com.noble.glamour.module.logic.application.App;
import com.noble.library.view.base.BaseDialogFragment;
import com.noble.meether.logic.third.share.QRDialog;
import com.noble.meether.logic.third.share.ShareUtils;
import com.noble.meether.logic.third.share.util.ShareEnum;

/**
 * 分享弹出框
 */
public class ShareDialog extends BaseDialogFragment implements View.OnClickListener {
    public ShareDialog() {
        settWindowAnimations(R.style.AnimDownInDownOutOverShoot);
        setGravity(Gravity.BOTTOM);
        setDialogSizeRatio(-2, -1);
        setCancelable(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        setContentView(R.layout.share_dialog);
        initView();
        return getContentView();
    }

    private void initView() {
        findViewById(R.id.share_weixin).setOnClickListener(this);
        findViewById(R.id.share_wx_circle).setOnClickListener(this);
        findViewById(R.id.share_qq_friend).setOnClickListener(this);
        findViewById(R.id.share_qq_zone).setOnClickListener(this);
        findViewById(R.id.share_link).setOnClickListener(this);
        findViewById(R.id.share_qr).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.share_weixin:
                ShareUtils.getInstance().shareData((Activity) App.getActivity(), ShareEnum.WEIXIN);
                break;
            case R.id.share_wx_circle:
                ShareUtils.getInstance().shareData((Activity) App.getActivity(), ShareEnum.WEIXIN_FRIENDS);
                break;
            case R.id.share_qq_friend:
                ShareUtils.getInstance().shareData((Activity) App.getActivity(), ShareEnum.QQ);
                break;
            case R.id.share_qq_zone:
                ShareUtils.getInstance().shareData((Activity) App.getActivity(), ShareEnum.QQ_ZONE);
                break;
            case R.id.share_link:
                ShareUtils.getInstance().shareData((Activity) App.getActivity(), ShareEnum.COPY);
                break;
            case R.id.share_qr:
                QRDialog dialog = new QRDialog();
                dialog.showDialog((FragmentActivity) App.getActivity());
                break;
        }
    }
}
